package com.zmykj.hik.hikService.Service.Stream;

import java.util.Arrays;
import java.util.List;

import com.sun.jna.NativeLong;
import com.sun.jna.Pointer;
import com.sun.jna.Structure;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.NativeLongByReference;
import com.sun.jna.win32.StdCallLibrary;

public interface PlayCtrlByJNA extends StdCallLibrary{

	final public int STREAME_REALTIME = 0;
    final public int STREAME_FILE = 1;
    final public int T_UYVY = 1;
    final public int T_YV12 = 3;
    final public int T_RGB32 = 7;

    public boolean PlayM4_GetPort(NativeLongByReference nPort);

    public boolean PlayM4_OpenStream(NativeLong nPort, Pointer pFileHeadBuf, int nSize, int nBufPoolSize);

    public boolean PlayM4_InputData(NativeLong nPort, Pointer pBuf, int nSize);

    public boolean PlayM4_CloseStream(NativeLong nPort);

    public boolean PlayM4_SetStreamOpenMode(NativeLong nPort, int nMode);

    public boolean PlayM4_Play(NativeLong nPort, Pointer hWnd);

    public boolean PlayM4_PlaySound(NativeLong nPort);

    public boolean PlayM4_Stop(NativeLong nPort);

    public boolean PlayM4_FreePort(NativeLong nPort);

    public boolean PlayM4_SetSecretKey(NativeLong nPort, NativeLong lKeyType, String pSecretKey, NativeLong lKeyLen);

    public boolean PlayM4_GetJPEG(NativeLong nPort, byte[] pJpeg, int nBufSize, IntByReference pJpegSize);

    public boolean PlayM4_SetDecCallBack(NativeLong nPort, DecCallBack decCBFun);

    public boolean PlayM4_SetDecCallBackMend(NativeLong nPort, DecCallBack decCBFun, long nUser);

    public boolean PlayM4_SetDecCallBackExMend(NativeLong nPort, DecCallBack decCBFun, Pointer pDest, long nDestSize, long nUser);

    public int PlayM4_GetLastError(NativeLong nPort);

    interface DecCallBack extends StdCallCallback {
        void invoke(NativeLong nPort, Pointer pBuf, int nSize, FRAME_INFO pFrameInfo, NativeLong nReserved1, NativeLong nReserved2);
    }


    public class FRAME_INFO extends Structure
    {
        public NativeLong nWidth;                     
        public NativeLong nHeight;                       
        public NativeLong nStamp;                             
        public NativeLong nType;                              
        public NativeLong nFrameRate;                  
        public int dwFrameNum;                        
		@Override
		protected List<String> getFieldOrder() {
			return Arrays.asList("nWidth","nHeight","nStamp","nType", "nFrameRate", "dwFrameNum");
		}
    }
}
